package com.xiaoqi.store.service.impl;

import com.xiaoqi.store.dao.DistrictMapper;
import com.xiaoqi.store.entity.DistrictsEntity;
import com.xiaoqi.store.exception.impl.DistrictsException;
import com.xiaoqi.store.service.DistrictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author Rookie Coder
 * @Description 省市区三级联动业务实现层
 * @Date
 **/
@Service
@Slf4j
public class DistrictsEntityImpl implements DistrictService {

    @Autowired
    private DistrictMapper districtMapper;

    /*
    * @Author xiaoqi
    * @Description  省市区三级联动
    * @return
    **/

    @Override
    public List<DistrictsEntity> getAllDistricts(String parent) {
        List<DistrictsEntity> DistrictsEntityList = districtMapper.getAllDistricts(parent);
        if (DistrictsEntityList ==null){
            log.info("系统获取地址坐标出现错误，请稍后再试");
            throw new DistrictsException("系统获取地址坐标出现错误，请稍后再试");
        }
        return DistrictsEntityList;
    }
}
